package ua.kpi.oblamskyiv.parser;

import ua.kpi.oblamskyiv.io.exception.IllegalAnswerFormatException;
import ua.kpi.oblamskyiv.io.exception.IllegalAnswersNumberException;
import ua.kpi.oblamskyiv.testcase.Answers;
import ua.kpi.oblamskyiv.testcase.question.Question;

public class SingleIndexAnswerParser extends IndexAnswersParser {
    private static final int ANSWERS_NUMBER = 1;

    @Override
    public Answers parse(Question question, String rawString)
            throws IllegalAnswerFormatException {
        int[] indexes = parseAnswersIndexes(rawString);
        if (indexes.length != ANSWERS_NUMBER) {
            throw new IllegalAnswersNumberException();
        }
        return super.parse(question, rawString);
    }
}
